package com.geek.base.ch02.videodemo;

import java.util.Scanner;

/*
 *@Date 2025/11/8
 *@Author wangpeng
 *@Description TODO
 */
public class WhileTest {

    public static void main(String[] args) {
        //输出1~100之间的偶数
        int i = 2;
        //while(条件) 循环  必须条件满足时才能进入循环
        while (i<=100){
            System.out.println("偶数 = "+i);
            i+=2;
        }

        System.out.println("-----------------");
        //do....while()
        int a = 2;
        do{
            System.out.println("仍然会先执行一次");
        }while (a>3);

        System.out.println("-----------------");
        Scanner sc = new Scanner(System.in);
        //死循环
        while (true){
            System.out.println("请输入：");
            String line = sc.nextLine();
            if(line.equals("exit")){
                //跳出当前循环
                break;
            }

            System.out.println("line = "+line);
        }
    }

}